﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;
public partial class HY_Default : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    private static readonly HotelBLL bllHotel = new HotelBLL();
    private static readonly PicturesBLL bllPictures = new PicturesBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindInfo();
            BindHY();
            BindCase();
        }
    }
    public void BindInfo()
    {
        Category model = bllCategory.GetModel("hyfwnr");
        if (model != null)
        {
            lblContent.Text = model.description;
        }
    }

    //推荐
    public void BindHY()
    {
        this.rptHotelHYList.DataSource = bllHotel.GetList("typeid=" + bllCategory.GetIdByCodeNo("hyxjd"));
        rptHotelHYList.DataBind();
    }

    //案例
    public void BindCase()
    {
        int recount = 0;
        this.rptCaseList.DataSource = bllNews.GetList(20, 1, "jdcgal", out recount);
        rptCaseList.DataBind();
    }
    public string GetPic(object pid, object tid)
    {
        string imgsrc = string.Empty;
        try
        {
            imgsrc = bllPictures.GetModel(int.Parse(pid + ""), int.Parse(tid + "")).imgPath;

        }
        catch
        {
            imgsrc = string.Empty;
        }
        if (!string.IsNullOrEmpty(imgsrc))
        {
            return "uploads/" + imgsrc;
        }
        else
        {
            return "images/nopic.jpg";
        }
    }

    public string SetStarWidth(object obj)
    {
        try
        {
            int num = int.Parse(obj + "");
            return num * 12 + "";
        }
        catch
        {
            return "0";
        }
    }
}
